<template>
	<xn-form-container
		:title="formData.id ? '编辑商品信息' : '增加商品信息'"
		:width="700"
		v-model:open="open"
		:destroy-on-close="true"
		@close="onClose"
	>
		<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
			<a-tabs v-model:activeKey="activeTabsKey">
				<a-tab-pane key="1" tab="基础信息" force-render>
					<a-row :gutter="16">
						<a-col :span="12">
							<a-form-item label="是否计库存：" name="productionIsstock">
								<a-radio-group
									v-model:value="formData.productionIsstock"
									placeholder="请选择是否计库存"
									:options="productionIsstockOptions"
								/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="库存：" name="productionStock">
								<a-input disabled v-model:value="formData.productionStock" required style="border: none;box-shadow: none;background-color: transparent;" placeholder="请输入库存"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="一品多码：" name="productionHasextbarcode">
								<a-radio-group
									v-model:value="formData.productionHasextbarcode"
									placeholder="请选择一品多码"
									:options="productionHasextbarcodeOptions"
								/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="商品状态：" name="productionStatus">
								<a-radio-group
									v-model:value="formData.productionStatus"
									placeholder="请选择商品状态"
									:options="productionStatusOptions"
								/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="商品编码：" name="productionCode">
								<a-input v-model:value="formData.productionCode" placeholder="请输入商品编码"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="主条码：" name="productionBarcode">
								<a-input v-model:value="formData.productionBarcode" placeholder="请输入主条码"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="商品名称：" name="productionName">
								<a-input v-model:value="formData.productionName" placeholder="请输入商品名称"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="商品分类：" name="productionCategoriesId">
								<a-tree-select
									v-model:value="formData.productionCategoriesId"
									class="xn-wd"
									:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
									placeholder="请选择商品分类"
									allow-clear
									tree-default-expand-all
									:tree-data="treeData"
									:tree-default-expanded-keys="treeDefaultExpandedKeys"
									:field-names="{
										children: 'children',
										label: 'name',
										value: 'id'
									}"
								></a-tree-select>
							</a-form-item>
						</a-col>

						<a-col :span="12">
							<a-form-item label="品牌：" name="productionBrand">
								<xn-page-select
									ref="xnproductionBrandPageSelectRef"
									v-model:value="formData.productionBrand"
									placeholder="请选择品牌"
									allow-clear
									show-search
									:page-function="productionBrandSelector"
									:echo-function="productionBrandEcho"
								/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="单位：" name="productionUnit">
								<xn-page-select
									ref="xnproductionUnitPageSelectRef"
									v-model:value="formData.productionUnit"
									placeholder="请选择单位"
									allow-clear
									show-search
									:page-function="productionUnitSelector"
									:echo-function="productionUnitEcho"
								/>
							</a-form-item>
						</a-col>


						<a-col :span="24">
							<span >辅助单位： &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  <a-button type="link" style="color: blue" @click="addUnitAuxiliary" >添加</a-button></span>
							<s-table
								v-if="unitAuxiliary!==null"
								ref="unitAuxiliaryTableRef"
								:columns="unitAuxiliaryColumns"
								:data="unitAuxiliaryLoadData"
								:alert="false"
								:show-pagination="false"
								bordered
							>
								<template #bodyCell="{ column, record }">
									<template v-if="column.dataIndex === 'unit'">
										<a-input v-model:value="unitAuxiliary[record.index-1].unit" required style="border: none;box-shadow: none;background-color: transparent; text-align: center" placeholder="请输入辅助单位"
										/>
									</template>
									<template v-if="column.dataIndex === 'conversion'">
										<a-input v-model:value="unitAuxiliary[record.index-1].conversion" style="border: none;box-shadow: none;background-color: transparent;text-align: center" placeholder="请输入与主单位换算关系"
										/>
									</template>
									<template v-if="column.dataIndex === 'action'">
										<a-space>
											<a-popconfirm title="确定要删除吗？" @confirm="deleteUnitAuxiliary(record)">
												<a-button type="link" danger size="small" >删除</a-button>
											</a-popconfirm>
										</a-space>
									</template>
								</template>
							</s-table>
						</a-col>
						<a-col :span="24" style="height: 20px" ></a-col>
						<a-col :span="12">
							<a-form-item label="规格：" name="productionSpec">
								<a-input v-model:value="formData.productionSpec" placeholder="请输入商品规格"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="保质期：" name="productionExp">
								<a-input v-model:value="formData.productionExp" placeholder="请输入保质期" allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="库存上限：" name="productionStockUp">
								<a-input v-model:value="formData.productionStockUp" default-value="0" placeholder="请输入库存上限"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="库存下限：" name="productionStockLow">
								<a-input v-model:value="formData.productionStockLow" default-value="0" placeholder="请输入库存下限"
										 allow-clear/>
							</a-form-item>
						</a-col>

						<a-col :span="12">
							<a-form-item label="主供应商：" name="productionSupplierMain">
								<xn-page-select
									ref="xnproductionSupplierMainPageSelectRef"
									v-model:value="formData.productionSupplierMain"
									placeholder="请选择主供应商"
									allow-clear
									show-search
									:page-function="productionSupplierMainSelector"
									:echo-function="productionSupplierMainEcho"
								/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="供应商列表：" name="productionSupplierList">
								<xn-page-select
									ref="xnproductionSupplierListPageSelectRef"
									v-model:value="formData.productionSupplierList"
									placeholder="请选择其他供应商"
									allow-clear
									show-search
									mode="multiple"
									:page-function="productionSupplierListSelector"
									:echo-function="productionSupplierListEcho"
								/>
							</a-form-item>
						</a-col>


						<a-col :span="12">
							<a-form-item label="排序码：" name="sortCode">
								<a-input v-model:value="formData.sortCode" placeholder="请输入排序码" allow-clear/>
							</a-form-item>
						</a-col>
					</a-row>
				</a-tab-pane>
				<a-tab-pane key="2" tab="价格信息" force-render>
					<a-row :gutter="16">
						<a-col :span="12">
							<a-form-item label="采购单价：" name="productionPriceProcure">
								<a-input prefix="￥" suffix="RMB" v-model:value="formData.productionPriceProcure" placeholder="请输入采购单价"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="最近一次采购单价：" name="productionPriceProcureLast">
								<a-input prefix="￥" suffix="RMB" v-model:value="formData.productionPriceProcureLast" disabled
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="销售单价：" name="productionPriceSale">
								<a-input prefix="￥" suffix="RMB" v-model:value="formData.productionPriceSale" placeholder="请输入销售单价"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="批发单价：" name="productionPriceWhole">
								<a-input prefix="￥" suffix="RMB" v-model:value="formData.productionPriceWhole" placeholder="请输入批发单价"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="最低销售单价：" name="productionPriceLimit">
								<a-input prefix="￥" suffix="RMB" v-model:value="formData.productionPriceLimit" placeholder="请输入最低销售单价"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="建议零售单价：" name="productionPriceRetail">
								<a-input prefix="￥" suffix="RMB" v-model:value="formData.productionPriceRetail" placeholder="请输入建议零售价"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<span >客户等级价格： &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  <a-switch
								:loading="loading"
								:checked="formData.productionPriceCustomTypeSwitch=='true'"
								@change="changeCustomTypePrice"
							>启用</a-switch></span>
							<s-table
								v-if="formData.productionPriceCustomTypeSwitch=='true'"
								ref="customtypePriceTableRef"
								:columns="customTypePriceColumns"
								:data="customtypePriceLoadData"
								:alert="options.alert.show"
								:show-pagination="false"
								bordered
							>
								<template #bodyCell="{ column, record }">
									<template v-if="column.dataIndex === 'price'">
										<a-input prefix="￥" suffix="RMB" v-model:value="customtypePrice[record.index-1].price" style="border: none;box-shadow: none;background-color: transparent;text-align: center " placeholder="请输入客户等级单价"
										/>
									</template>
								</template>
							</s-table>
						</a-col>
					</a-row>
				</a-tab-pane>

				<a-tab-pane key="3" tab="扩展信息" force-render>
					<a-row :gutter="16">
						<a-col :span="16">
							<a-form-item label="产地：" name="productionOrigin">
								<a-input v-model:value="formData.productionOrigin" placeholder="请输入产地"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="8">
							<a-form-item label="是否线上销售：" name="productionOnlineSwitch">
								<a-radio-group
									v-model:value="formData.productionOnlineSwitch"
									placeholder="请选择是否线上销售"
									:options="productionOnlineSwitchOptions"
								/>
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="商品标题：" name="productionTitle">
								<a-input v-model:value="formData.productionTitle" placeholder="请输入商品标题"
										 allow-clear/>
							</a-form-item>
						</a-col>

						<a-col :span="24">
							<a-form-item label="商品标签：" name="productionTag">
								<a-input v-model:value="formData.productionTag" placeholder="请输入商品标签"
										 allow-clear/>
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="商品图片：" name="productionImages">
								<xn-upload v-model:value="formData.productionImages" imageNumber="4" uploadMode="image"/>
							</a-form-item>
						</a-col>
						<a-col :span="24">
							<a-form-item label="商品描述：" name="productionDescribe">
								<xn-editor v-model:value="formData.productionDescribe" placeholder="请输入商品描述"/>
							</a-form-item>
						</a-col>
					</a-row>
				</a-tab-pane>
				<a-tab-pane key="4" tab="库位信息" force-render>
					<a-row :gutter="16">
						<a-col :span="24">
							<span >库位信息： &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp  </span>
							<s-table
								ref="storageLocationTableRef"
								:columns="storageLocationColumns"
								:data="storageLocationLoadData"
								:alert="false"
								:show-pagination="false"
								bordered
							>
								<template #bodyCell="{ column, record }">
									<template v-if="column.dataIndex === 'unit'">
										<a-input v-model:value="unitAuxiliary[record.index-1].unit" required style="border: none;box-shadow: none;background-color: transparent; text-align: center" placeholder="请输入辅助单位"
										/>
									</template>
									<template v-if="column.dataIndex === 'conversion'">
										<a-input v-model:value="unitAuxiliary[record.index-1].conversion" style="border: none;box-shadow: none;background-color: transparent;text-align: center" placeholder="请输入与主单位换算关系"
										/>
									</template>
									<template v-if="column.dataIndex === 'action'">
										<a-space>
											<a-popconfirm title="确定要删除吗？" @confirm="deleteUnitAuxiliary(record)">
												<a-button type="link" danger size="small" >删除</a-button>
											</a-popconfirm>
										</a-space>
									</template>
								</template>
							</s-table>
						</a-col>
					</a-row>
				</a-tab-pane>
			</a-tabs>
		</a-form>
		<template #footer>
			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
		</template>
	</xn-form-container>
</template>

<script setup name="supplierProductionForm">
import tool from '@/utils/tool'
import {cloneDeep} from 'lodash-es'
import {required} from '@/utils/formRules'
import supplierProductionsApi from '@/api/supplier/base/supplierProductionsApi'
import supplierBrandsApi from '@/api/supplier/base/supplierBrandsApi'
import supplierCategoriesApi from '@/api/supplier/base/supplierCategoriesApi'
import supplierUnitsApi from "@/api/supplier/base/supplierUnitsApi";
import supplierSuppliersApi from "@/api/supplier/purchase/supplierSuppliersApi";
import supplierCustomTypeApi from "@/api/supplier/custom/supplierCustomTypeApi";
import supplierStocksApi from "@/api/supplier/warehouse/supplierStocksApi";
import supplierObjectsApi from "@/api/supplier/custom/supplierObjectsApi";


// 抽屉状态
const open = ref(false)
const emit = defineEmits({successful: null})
const formRef = ref()
const activeTabsKey = ref('1')
// 表单数据
const formData = ref({})
const customtypePrice =ref([])
const unitAuxiliary = ref(null)
const loading = ref(false)
const customtypePriceTableRef = ref()
const unitAuxiliaryTableRef = ref()
const storageLocationTableRef = ref()

const changeCustomTypePrice=()=>{
	if(formData.value.productionPriceCustomTypeSwitch=='true'){
		formData.value.productionPriceCustomTypeSwitch = 'false'
	}else{
		formData.value.productionPriceCustomTypeSwitch = 'true'
	}
	// customtypePriceTableRef.value.refresh(true)
}
const customTypePriceColumns = [
	{
		title: '序号',
		dataIndex: 'index',
		align: 'center',
	},
	{
		title: '客户类型',
		dataIndex: 'customType',
		align: 'center',
	},
	{
		title: '商品价格',
		dataIndex: 'price',
		align: 'center',
		width: '200px'
	}
]
const unitAuxiliaryColumns = [
	{
		title:'序号',
		dataIndex: 'index',
		align:'center'
	},
	{
		title:'单位',
		dataIndex: 'unit',
		align: 'center',
		width: '200px'
	},
	{
		title:'与主单位换算关系',
		dataIndex:'conversion',
		align: 'center'
	},
	{
		title: '操作',
		dataIndex: 'action',
		align: 'center',
		width: 150
	}
]
const storageLocationColumns = [
	{
		title: '门店',
		dataIndex: 'stockStoreIdName',
		align: 'center',
	},
	{
		title: '仓库',
		dataIndex: 'stockStorageIdName',
		align: 'center'
	},
	{
		title: '批次',
		dataIndex: 'stockBatch',
		align: 'center'
	},
	{
		title: '库位',
		dataIndex: 'stockStoreLocationName',
		align: 'center'
	},
	{
		title: '供应商',
		dataIndex: 'stockSupplierName',
		align: 'center'
	},
	{
		title: '库存',
		dataIndex: 'stockStock',
		align: 'center'
	}
]
const customtypePriceLoadData = async () => {
	const records = []  //定义数据集
	await supplierCustomTypeApi.supplierCustomTypeList().then((res)=>{  //先获取所有客户类型
		for(let i=0;i<res.length;i++){
			let price =formData.value.productionPriceSale //初始化价格，如果商品库中没有该客户类型的价格，则用零售价来作为等级价格
			if(formData.value.productionPriceCustomType!=null && formData.value.productionPriceCustomType!==''){
				formData.value.productionPriceCustomType.forEach(typePrice=>{//去商品库的等级价格中查询对应的记录，
					if(typePrice.customTypeId===res[i].id){
						price = typePrice.price
					}
				})
			}
			const record ={
				index:i+1,
				customTypeId:res[i].id,
				customType:res[i].customTypeName,
				price:price
			}
			records.push(record)
		}
	})
	const tableDate = {
		current:1,
		pages:1,
		records:records,
		size:100,
		total:1
	}
	customtypePrice.value = tableDate.records
	return Promise.resolve(tableDate)
}
const unitAuxiliaryLoadData = async () =>{
	const tableDate = {
		current:1,
		pages:1,
		records:unitAuxiliary.value,
		size:unitAuxiliary.value.length,
		total:1
	}
	return Promise.resolve(tableDate)
}
const addUnitAuxiliary = ()=>{
	const units = unitAuxiliary.value ==null ? [] : unitAuxiliary.value;
	const addUnit = {
		index:units.length+1,
		unit:"",
		conversion:""
	}
	units.push(addUnit);
	unitAuxiliary.value = units;
}
const deleteUnitAuxiliary = (record) =>{
	for(let i=record.index-1;i<unitAuxiliary.value.length-1;i++){
		unitAuxiliary.value[i].unit = unitAuxiliary.value[i+1].unit
		unitAuxiliary.value[i].conversion = unitAuxiliary.value[i+1].conversion
	}
	unitAuxiliary.value.splice(unitAuxiliary.value.length-1,1)
	if(unitAuxiliary.value.length===0){
		unitAuxiliary.value = null
	}
}
const storageLocationLoadData = (parameter) =>{
	return supplierStocksApi.supplierStocksPage(Object.assign(parameter, {stockProductionId:formData.value.id})).then((data) => {
		return data
	})
}
const selectedRowKeys = ref([])
// 列表选择配置
const options = {
	// columns数字类型字段加入 needTotal: true 可以勾选自动算账
	alert: {
		show: false,
		clear: () => {
			selectedRowKeys.value = ref([])
		}
	},
	rowSelection: {
		onChange: (selectedRowKey) => {
			selectedRowKeys.value = selectedRowKey
		}
	}
}

const treeData = ref([])
const treeDefaultExpandedKeys = ref([])
nextTick(() => {
	// 机构选择器数据
	supplierCategoriesApi.categoriesTreeSelector().then((res) => {
		if (res !== null) {
			treeData.value = res
			// 默认展开2级
			treeData.value.forEach((item) => {
				// 因为0的顶级
				if (item.parentId === '0') {
					treeDefaultExpandedKeys.value.push(item.id)
					// 取到下级ID
					if (item.children) {
						item.children.forEach((items) => {
							treeDefaultExpandedKeys.value.push(items.id)
						})
					}
				}
			})
		}
	})
})
const submitLoading = ref(false)
const xnproductionBrandPageSelectRef = ref()
const productionBrandSelector = async (param) => {
	let data = await supplierBrandsApi.supplierBrandsPage(param);
	if (data.records) {
		data.records = data.records.map((item) => {
			return {
				name: item.brandName,
				id: item.brandName
			}
		})
	}
	return Promise.resolve(data)
}
const productionBrandEcho = (param) => {
	let echoList = []
	let echo =  {}
	for(var i=0;i<param.idList[0].length;i++){
		echo.name = formData.value.productionBrandName
		echo.id = param.idList[0][i]
		echoList.push(echo)
	}
	return Promise.resolve(echoList)
}

const xnproductionUnitPageSelectRef = ref()
const productionUnitSelector = async (param) => {
	let data = await supplierUnitsApi.supplierUnitsPage(param);
	if (data.records) {
		data.records = data.records.map((item) => {
			return {
				name: item.unitName,
				id: item.unitName
			}
		})
	}
	return Promise.resolve(data)
}
const productionUnitEcho = (param) => {
	let echoList = []
	let echo =  {}
	for(var i=0;i<param.idList[0].length;i++){
		echo.name = formData.value.productionUnitName
		echo.id = param.idList[0][i]
		echoList.push(echo)
	}
	return Promise.resolve(echoList)
}

const productionIsstockOptions = ref([])
productionIsstockOptions.value = tool.dictList('COMMON_SWITCH')
const productionOnlineSwitchOptions = ref([])
productionOnlineSwitchOptions.value = tool.dictList('COMMON_STATUS')

const xnproductionSupplierMainPageSelectRef = ref()
const productionSupplierMainSelector = async (param) => {
	let data = await supplierObjectsApi.supplierObjectsPage(Object.assign(param, {objectType:"0"}));
	if (data.records) {
		data.records = data.records.map((item) => {
			return {
				name: item.objectName,
				id: item.id
			}
		})
	}
	return Promise.resolve(data)
}
const productionSupplierMainEcho = (param) => {
	let echoList = []
	let echo =  {}
	for(var i=0;i<param.idList[0].length;i++){
		echo.name = formData.value.productionSupplierMainName
		echo.id = param.idList[0][i]
		echoList.push(echo)
	}
	return Promise.resolve(echoList)
}

const xnproductionSupplierListPageSelectRef = ref()
const productionSupplierListSelector = async (param) => {
	let data = await supplierObjectsApi.supplierObjectsPage(Object.assign(param, {objectType:"0"}));
	if (data.records) {
		data.records = data.records.map((item) => {
			return {
				name: item.objectName,
				id: item.id
			}
		})
	}
	return Promise.resolve(data)
}
const productionSupplierListEcho = (param) => {
	let echoList = []
	let echo =  {}
	console.log(param.idList)
	for(var i=0;i<param.idList[0].length;i++){
		echo.name = formData.value.productionSupplierListName[i]
		echo.id = param.idList[0][i]
		echoList.push(echo)
	}
	return Promise.resolve(echoList)
}

const productionStatusOptions = ref([])
const productionHasextbarcodeOptions = ref([])

// 打开抽屉
const onOpen = (record,categoriesId) => {
	console.log(categoriesId)
	open.value = true
	unitAuxiliary.value = null
	customtypePrice.value = null
	if (record) {
		let recordData = cloneDeep(record)
		formData.value = Object.assign({}, recordData)
		unitAuxiliary.value = formData.value.productionUnitAuxiliary===null ? null : JSON.parse(formData.value.productionUnitAuxiliary)
		formData.value.productionPriceCustomType =  formData.value.productionPriceCustomType==null ? null : formData.value.productionPriceCustomType==='' ? null : JSON.parse(formData.value.productionPriceCustomType)
		formData.value.productionSupplierList = formData.value.productionSupplierList == null ? null :  formData.value.productionSupplierList === '' ? null : formData.value.productionSupplierList.split(",")
		formData.value.productionSupplierListName = formData.value.productionSupplierListName == null ? null :  formData.value.productionSupplierListName === '' ? null : formData.value.productionSupplierListName.split(",")
	}else{
		formData.value.productionIsstock = 'true'
		formData.value.productionStock = 0
		formData.value.productionHasextbarcode = 'ENABLE'
		formData.value.productionStatus = 'ENABLE'
		formData.value.productionPriceProcure = 0
		formData.value.productionPriceSale = 0
		formData.value.productionPriceWhole = 0
		formData.value.productionPriceLimit = 0
		formData.value.productionPriceCustomType = []
		formData.value.productionCategoriesId = categoriesId

	}
	nextTick(() => {
		xnproductionBrandPageSelectRef.value.onPage({current: 1})
	})
	nextTick(() => {
		xnproductionUnitPageSelectRef.value.onPage({current: 1})
	})
	nextTick(() => {
		xnproductionSupplierMainPageSelectRef.value.onPage({current: 1})
		xnproductionSupplierListPageSelectRef.value.onPage({current: 1})
	})
	productionStatusOptions.value = tool.dictList('COMMON_STATUS')
	productionHasextbarcodeOptions.value = tool.dictList('COMMON_STATUS')
}
// 关闭抽屉
const onClose = () => {
	formRef.value.resetFields()
	formData.value = {}
	open.value = false
}
// 默认要校验的
const formRules = {
	productionCode: [required('请输入商品编码')],
	productionBarcode: [required('请输入主条码')],
	productionName: [required('请输入商品名称')],
	productionCategoriesId: [required('请选择商品分类')]
}
// 验证并提交数据
const onSubmit = () => {
	formRef.value
		.validate()
		.then(() => {
			submitLoading.value = true
			const formDataParam = cloneDeep(formData.value)
			console.log(formDataParam)
			if(formDataParam.productionPriceCustomTypeSwitch === 'true'){
				formDataParam.productionPriceCustomType = JSON.stringify(customtypePrice.value)
			}else{
				formDataParam.productionPriceCustomType = null
			}
			console.log(formDataParam)
			if(unitAuxiliary.value){
				formDataParam.productionUnitAuxiliary = JSON.stringify(unitAuxiliary.value)
			}else{
				formDataParam.productionUnitAuxiliary = null
			}
			console.log(formDataParam)
			if(formDataParam.productionSupplierList){
				formDataParam.productionSupplierList = formDataParam.productionSupplierList.join(",")
			}
			console.log(formDataParam)
			if (formDataParam.productionSupplierList!==null && formDataParam.productionSupplierList.substring(0, 1) === ",") {
				formDataParam.productionSupplierList = formDataParam.productionSupplierList.substring(1)
			}
			console.log(formDataParam)

			supplierProductionsApi
				.supplierProductionsSubmitForm(formDataParam, formDataParam.id)
				.then(() => {
					onClose()
					emit('successful')
				})
				.finally(() => {
					submitLoading.value = false
				})
		})
		.catch(() => {
		})
}
// 抛出函数
defineExpose({
	onOpen
})
</script>
<style scoped lang="less">
.form-row {
	background-color: var(--item-hover-bg);
	margin-left: 0 !important;
	margin-bottom: 10px;
}
.form-row-con {
	padding-bottom: 5px;
	padding-top: 5px;
	padding-left: 15px;
}
</style>
